package net.lab1024.sa.admin.module.business.yct.yctTeeth.controller;

import net.lab1024.sa.admin.module.business.yct.yctTeeth.domain.form.ArticleAddForm;
import net.lab1024.sa.admin.module.business.yct.yctTeeth.domain.form.ArticleQueryForm;
import net.lab1024.sa.admin.module.business.yct.yctTeeth.domain.form.ArticleUpdateForm;
import net.lab1024.sa.admin.module.business.yct.yctTeeth.domain.vo.ArticleVO;
import net.lab1024.sa.admin.module.business.yct.yctTeeth.domain.vo.YctTeethHospitalVO;
import net.lab1024.sa.admin.module.business.yct.yctTeeth.service.ArticleService;
import net.lab1024.sa.base.common.annoation.NoNeedLogin;
import net.lab1024.sa.base.common.domain.ValidateList;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.*;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 文章 Controller
 *
 * @Author zhangben
 * @Date 2024-12-18 09:52:35
 * @Copyright 20241218
 */

@RestController
@Tag(name = "文章")
public class ArticleController {

    @Resource
    private ArticleService articleService;

    @Operation(summary = "分页查询 @author zhangben")
    @PostMapping("/article/queryPage")
    @SaCheckPermission("article:query")
    @NoNeedLogin
    public ResponseDTO<PageResult<ArticleVO>> queryPage(@RequestBody @Valid ArticleQueryForm queryForm) {
        return ResponseDTO.ok(articleService.queryPage(queryForm));
    }

    @NoNeedLogin
    @GetMapping("/article/select/{articleId}")
    public ResponseDTO<ArticleVO> select(@PathVariable Integer articleId) {
        return ResponseDTO.ok(articleService.select(articleId));
    }

    @Operation(summary = "添加 @author zhangben")
    @PostMapping("/article/add")
    @SaCheckPermission("article:add")
    public ResponseDTO<String> add(@RequestBody @Valid ArticleAddForm addForm) {
        return articleService.add(addForm);
    }

    @Operation(summary = "更新 @author zhangben")
    @PostMapping("/article/update")
    @SaCheckPermission("article:update")
    public ResponseDTO<String> update(@RequestBody @Valid ArticleUpdateForm updateForm) {
        return articleService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author zhangben")
    @PostMapping("/article/batchDelete")
    @SaCheckPermission("article:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return articleService.batchDelete(idList);
    }

}
